home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / MM2_DEV / S / TEST / MINTBUG1.M < prev    next >
Encoding:
Text File  |  1992-02-19  |  1.9 KB  |  77 lines

  1. MODULE MiNTBug1;
  2. (*$C-,N+,R-,L-*)
  3.  
  4. (*
  5.  * this program shows, that after a Pterm() call the next Supexec() call
  6.  * terminates the program anyway.
  7.  * if it would run correctly, the exitcode would be 4567. instead, it is 1234.
  8.  *
  9.  * NOTE: link with no additional startup code!
  10.  *)
  11.  
  12. FROM SYSTEM IMPORT ASSEMBLER;
  13.  
  14. BEGIN
  15.   ASSEMBLER
  16.         ;illegal         ; to call resident debugger (e.g. templemon)
  17.         
  18.         ; save usp
  19.         lea     _usp(pc),a0
  20.         move.l  a7,(a0)
  21.         
  22.         ; go into supervisor mode
  23.         clr.l   -(a7)
  24.         move    #$20,-(a7)
  25.         trap    #1
  26.         
  27.         ; save ssp
  28.         lea     _ssp(pc),a0
  29.         move.l  d0,(a0)
  30.         
  31.         ; install 'catch' in etv_term
  32.         lea     _term(pc),a0
  33.         move.l  $408,(a0)
  34.         lea     catch(pc),a0
  35.         move.l  a0,$408
  36.         
  37.         ; do Pterm(1234)
  38.         move    #1234,-(a7)
  39.         move    #$4c,-(a7)
  40.         trap    #1              ; execution will continue at 'catch'...
  41.         
  42. catch:  ;illegal         ; to call resident debugger (e.g. templemon)
  43.         
  44.         ; reload usp/ssp
  45.         move.l  _ssp(pc),a7
  46.         move.l  _usp(pc),a0
  47.         move.l  a0,usp
  48.         
  49.         ; restore etv_term
  50.         move.l  _term(pc),$408
  51.         
  52.         ; go from supervisor mode back to user mode
  53.         andi    #$dfff,sr
  54.         
  55.         ; now call Supexec(test), you'll see that it'll not return here
  56.         pea     test(pc)
  57.         move    #38,-(a7)
  58.         trap    #14
  59.         addq.l  #6,a7
  60.         
  61.         ; ERROR! this code gets never executed:
  62.         
  63.         ; do Pterm(4567)
  64.         move    #4567,-(a7)
  65.         move    #$4c,-(a7)
  66.         trap    #1
  67.  
  68. test:   ; do nothing
  69.         rts
  70.  
  71. _usp:   dc.l    0               ; to save usp
  72. _ssp:   dc.l    0               ; to save ssp
  73. _term:  dc.l    0               ; to save ($408)
  74.  
  75.   END
  76. END MiNTBug1.
  77.